package com.yunhe.common.constant;

import java.util.Objects;

/**
 * 权限常量定义
 * @author liuronglei
 */
public class AuthorityConsts {

    // 单位代码定义
    public enum FIRM_CODE {
        DEFAULT(11L, "默认"),
        NZ(1101L, "南自"),
        TB(1000L, "淘宝"),
        JSYD(110301L, "江苏移动"),
        SDXGS(1110L, "山东希格斯"),
        ZQ(1104L, "肇庆"),
        WSTAGC(1105L, "乌斯太AGC"),
        YONGALA(1108L, "Yongala"),
        ZNXSDC(1111L, "浙能萧山电厂"),
        JCDL(9999L, "家储代理");
        private final long value;
        private final String title;

        FIRM_CODE(long value, String title) {
            this.value = value;
            this.title = title;
        }

        public long value() {
            return value;
        }

        public String title() {
            return title;
        }
    }

    /**
     * 电站的终端类型
     *
     */
    public enum TerminalType {
        WEB(1,"WEB"), APP(2,"APP");

        private String title;
        private Integer value;

        TerminalType(Integer value, String title) {
            this.value = value;
            this.title = title;
        }

        public Integer getValue() {
            return value;
        }

        public void setValue(Integer value) {
            this.value = value;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public static TerminalType valueOf(Integer value) {
            switch (value) {
                case 1:
                    return WEB;
                case 2:
                    return APP;
                default:
                    return null;
            }
        }
    }

    /**
     * 角色分类
     *
     * @author diaoshili
     * @date 2019-8-28
     */
    public enum RoleName {
        ADMINSTRATOR("Admin","管理员",0), GENERAL_USER("GeneralUser","普通用户",1);
        private String title;
        private String name;
        private Integer value;

        RoleName(String name, String title, Integer value) {
            this.name = name;
            this.title = title;
            this.value = value;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Integer getValue() {
            return value;
        }

        public void setValue(Integer value) {
            this.value = value;
        }
    }


    /**
     * 菜单的分类类型
     *
     * @author diaoshili
     * @date 2019-8-28
     */
    public enum CategoryType {
        PLATFORM("平台", "Platform"),
        OPERATOR("运营商", "Operator"),
        FINAL_USER("终端用户", "FinalUser"),
        MAINTENANCE("运维商", "Maintenance"),
        BATTERY_HEALTH("电池健康分析", "Battery");
        private String title;
        private String value;

        CategoryType(String title, String value) {
            this.title = title;
            this.value = value;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        //平台视为特殊的运营商
        public static CategoryType valueOfByName(String name) {
            if (Objects.equals(name,"Platform")) {
                return CategoryType.OPERATOR;
            }
            for (CategoryType categoryType : CategoryType.values()) {
                if (Objects.equals(name,categoryType.getValue())) {
                    return categoryType;
                }
            }
            return null;
        }

        @Override
        public String toString() {
            return "CategoryType{" +
                    "title='" + title + '\'' +
                    ", value=" + value +
                    '}';
        }
    }

    /**
     * 菜单的分类类型
     *
     * @author diaoshili
     * @date 2019-8-28
     */
    public enum SystemType {
        SOLAR("光伏", 1),
        STORAGE("储能", 2);
        private String title;
        private Integer value;

        SystemType(String title, Integer value) {
            this.title = title;
            this.value = value;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public Integer getValue() {
            return value;
        }

        public void setValue(Integer value) {
            this.value = value;
        }

        public static SystemType valueOf(Integer value) {
            switch (value) {
                case 1:
                    return SOLAR;
                case 2:
                    return STORAGE;
                default:
                    return null;
            }
        }

        @Override
        public String toString() {
            return "CategoryType{" +
                    "title='" + title + '\'' +
                    ", value=" + value +
                    '}';
        }
    }

    public enum FirmTypeConstant {
        OPERATOR("Operator", 0L), MAINTENANCE("Maintenance", 1L), FINAL_USER("FinalUser", 2L), PLATFORM("Platform", 3L);
        private String name;
        private Long value;

        FirmTypeConstant(String name, Long value) {
            this.name = name;
            this.value = value;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Long getValue() {
            return value;
        }

        public void setValue(Long value) {
            this.value = value;
        }
    }

    public enum StationType {

        STORAGE("Storage", "储能"),
        SUPPORTING_SERVICE("SupportingService", "辅助服务"),
        SOLAR("Solar", "光伏"),
        HouseholdStorage("HouseholdStorage", "家庭储能"),
        Microgrid("Microgrid", "微电网");

        private final String value;
        private final String title;

        StationType(String value, String title) {
            this.value = value;
            this.title = title;
        }

        public String value() {
            return value;
        }
    }

    // 电站运行状态
    public enum StationStatusConstant {
        ACTIVE("activate", "已投产"),
        CONSTRUCTING("constructing", "建设中"),
        DEBUGGING("debugging", "调试中"),
        TESTING("testing", "试运行"),
        DEACTIVATED("deactivated", "已停运");
        private String title;
        private String value;
        StationStatusConstant(String value, String title) {
            this.value = value;
            this.title = title;
        }
        public String title() {
            return title;
        }
        public String value() {
            return value;
        }
        public boolean equals(String value) {
            return this.value().equals(value);
        }
    }

    // 用户状态
    public enum UserStatus {
        NORMAL(0d, "正常"),
        CONSTRUCTING(1d, "用户5分钟内登录失败"),
        DEBUGGING(2d, "用户正在登录中"),
        TESTING(-1d, "用户已锁定");
        private String title;
        private Double value;
        UserStatus(Double value, String title) {
            this.value = value;
            this.title = title;
        }
        public String title() {
            return title;
        }
        public Double value() {
            return value;
        }
        public boolean equals(Double value) {
            return this.value().equals(value);
        }
    }

    public enum StationOwnership {
        ALL("全部", "All"),
        PRIVATE("私有", "Private"),
        SHARED("被分享", "Shared");

        private String title;
        private String name;

        StationOwnership(String title, String name) {
            this.title = title;
            this.name = name;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    //家储代理电站code
    public static final Long HEMS_STATION_CODE = 9998L;
}
